package com.titar.robot.ui.control;

import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.titar.robot.R;
import com.titar.robot.base.BaseActivity;
import com.titar.robot.utils.ToastUtils;
import com.titar.robot.widgets.TntToolbar;


public class ControlActivity extends BaseActivity implements View.OnClickListener {


    private TextView control_action;
    private TextView control_voice;
    private TntToolbar tntToolbar;

    private ActionFragment actionFragment = new ActionFragment();
    private VoiceFragment voiceFragment = new VoiceFragment();

    @Override
    protected void onInitWidget(Bundle savedInstanceState) {
        control_action = findViewById(R.id.control_action);
        control_voice = findViewById(R.id.control_voice);

        tntToolbar = findViewById(R.id.tnt_toolbar);
        tntToolbar.getIvRight().setVisibility(View.VISIBLE);
        tntToolbar.getIvRight().setImageResource(R.drawable.block_save_img);
    }

    @Override
    protected void onInitListener() {
        control_action.setOnClickListener(this);
        control_voice.setOnClickListener(this);
        tntToolbar.getIvRight().setOnClickListener(this);

        repleaceFragment(actionFragment, R.id.control_fy);
        control_action.setSelected(true);
    }

    @Override
    public int getContentViewId() {
        return R.layout.layout_control_activity;
    }

    @Override
    public void onClick(View v) {
        unSelected();
        switch (v.getId()) {
            case R.id.control_action:
                control_action.setSelected(true);
                repleaceFragment(actionFragment, R.id.control_fy);
                break;
            case R.id.control_voice:
                control_voice.setSelected(true);
                repleaceFragment(voiceFragment, R.id.control_fy);
                break;
            case R.id.toolbar_iv_right:
                ToastUtils.showToast("保存编辑!");
                break;
        }
    }

    private void unSelected() {
        control_action.setSelected(false);
        control_voice.setSelected(false);
    }
}
